package listbyorder.access201_300.test300;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/28 17:07
 */
public class Solution2 {

    // 更新一位数组
    public int lengthOfLIS(int[] nums) {
        if (nums.length == 0) return 0;
        int n = nums.length;
        int[] dp = new int[n];
        int index = 0;
        for (int i = 1; i < n; i++) {
            int j = 0;
            for (; j < index; j++) {
                if (dp[j] >= nums[i]) {
                    break;
                }
            }
            dp[j] = nums[i];
            if (j == index) {
                index++;
            }
        }
        return index;
    }
}
